<?php

namespace app\models;

/**
 * This is the ActiveQuery class for [[ModBaseInfo]].
 *
 * @see ModBaseInfo
 */
class ModBaseInfoQuery extends \core\base\BaseQuery
{
    /*public function active()
    {
        return $this->andWhere('[[status]]=1');
    }*/

    /**
     * @inheritdoc
     * @return ModBaseInfo[]|array
     */
    public function all($db = null)
    {
        return parent::all($db);
    }

    /**
     * @inheritdoc
     * @return ModBaseInfo|array|null
     */
    public function one($db = null)
    {
        return parent::one($db);
    }

    public function search($args = [])
    {
        $this
            ->asArray()
            ->select(['*'])
            ->from(ModBaseInfo::tableName());
        if (!empty($args['page']) && empty($args['count'])) {
            $this->page($args['page']);
        }
        $search = $args['search'];
        if (!empty($search)) {
            $this->where([
                'or',
                ['like', 'name', $search],
                ['like', 'mobile', $search],
                ['like', 'email', $search],
                ['like', 'real_file_name', $search],
            ]);
        }
        if (!empty($args['count'])) {
            return $this->count();
        }
        return $this->all();
    }
}
